#ifndef FILESYS_DIRECTORY_H
#define FILESYS_DIRECTORY_H

#include <stdbool.h>
#include <stddef.h>
#include "devices/disk.h"
// 3 idiots added begin
#include "filesys/inode.h"

# define HEX_0 0x0
// 3 idiots added end

/* Maximum length of a file name component.
   This is the traditional UNIX maximum length.
   After directories are implemented, this maximum length may be
   retained, but much longer full path names must be allowed to use. */
#define NAME_MAX 14

/* A directory. */
struct dir 
  {
    struct inode *inode;                /* Backing store. */
    off_t pos;                          /* Current position. */
  };

/* A single directory entry. */
struct dir_entry 
  {
    disk_sector_t inode_sector;         /* Sector number of header. */
    char name[NAME_MAX + 1];            /* Null terminated file name. */
    bool in_use;                        /* In use or free? */
  };


struct inode;

/* Opening and closing directories. */
bool dir_create (disk_sector_t, disk_sector_t);
struct dir *dir_open (struct inode *);
struct dir *dir_open_root (void);
struct dir *dir_reopen (struct dir *);
void dir_close (struct dir *);
struct inode *dir_get_inode (struct dir *);

/* Reading and writing. */
bool dir_lookup (const struct dir *, const char *name, struct inode **);
bool dir_add (struct dir *, const char *name, disk_sector_t);
bool dir_remove (struct dir *, const char *name);
bool dir_readdir (struct dir *, char name[NAME_MAX + 1]);

bool dir_get_dir_path_and_file_name (char*, char**, char**);
char* dir_get_temp_path (const char*);
struct dir* dir_initialize (disk_sector_t);
struct dir* dir_get_directory (const char*);
struct dir* dir_get_by_path (char);
bool dir_none (struct dir*);

#endif /* filesys/directory.h  */
